const app = getApp();

Page({
    data: {
        message:'',
        autoObj:{
            minHeight: 100
        },
        placeholderText:'请输入',
        typeName:''
    },
    onLoad: function (options) {
        let {type,text,id}=options
        this.setData({
            typeName:type,
            message:text || '',
            id:id || ''
        })
        if(type==0){
            wx.setNavigationBarTitle({
                title:'店铺描述',
            })
        }
        if(type==1){
            wx.setNavigationBarTitle({
                title:'详细描述',
            })
        }
        if(type==2){
            wx.setNavigationBarTitle({
                title:'企业网址',
            })
            this.setData({
                placeholderText:'请输入企业网址',
            })
        }
        if(type==3){
            wx.setNavigationBarTitle({
                title:'稿件说明',
            })
            this.setData({
                placeholderText:'请输入稿件说明',
            })
        }
        if(type==4){
            wx.setNavigationBarTitle({
                title:'付款说明',
            })
            this.setData({
                placeholderText:'请输入付款说明',
            })
        }
        if(type==5){
            wx.setNavigationBarTitle({
                title:'意见反馈',
            })
            this.setData({
                placeholderText:'请输入方案反馈内容',
            })
        }
        if(type==6){
            wx.setNavigationBarTitle({
                title:'使用场景',
            })
        }
        if(type==7){
            wx.setNavigationBarTitle({
                title:'主题色',
            })
        }
        if(type==8){
            wx.setNavigationBarTitle({
                title:'竞品参考',
            })
        }
    },
    messageTap(){
        let pages = getCurrentPages();
        let prevPage = pages[pages.length - 2];
        if(this.data.typeName==0){
            prevPage.setData({
                talentDes:this.data.message
            })
            wx.navigateBack({
                delta: 1
            })
        }
        if(this.data.typeName==1){
            prevPage.setData({
                taskDescriptionVal:this.data.message
            })
            wx.navigateBack({
                delta: 1
            })
        }
        if(this.data.typeName==2){
            prevPage.setData({
                webUrlVal:this.data.message
            })
            wx.navigateBack({
                delta: 1
            })
        }
        if(this.data.typeName==3){
            prevPage.setData({
                takContributeVal:this.data.message
            })
            wx.navigateBack({
                delta: 1
            })
        }
        if(this.data.typeName==4){
            prevPage.setData({
                programDesc:this.data.message
            })
            wx.navigateBack({
                delta: 1
            })
        }
        if(this.data.typeName==5){
            this.submitBtn()
        }
        if(this.data.typeName==6){
            prevPage.setData({
                scene:this.data.message
            })
            wx.navigateBack({
                delta: 1
            })
        }
        if(this.data.typeName==7){
            prevPage.setData({
                maincolor:this.data.message
            })
            wx.navigateBack({
                delta: 1
            })
        }
        if(this.data.typeName==8){
            prevPage.setData({
                conference:this.data.message
            })
            wx.navigateBack({
                delta: 1
            })
        }

    },

    //提交方案意见反馈
    submitBtn(){
        var url = app.globalData.baseUrl + 'myTask/disagreePayType';
        var { id,message } = this.data;
        if(!message){
            wx.showToast({
                title: '请输入反馈信息',
                icon: 'none',
                duration: 2000
            })
            return
        }
        var data = {
            task_id: id,
            desc:message,
            token: app.globalData.token
        }
        wx.showLoading({
            title: '加载中',
        })
        app.wxPostRequest(url, data, (res) => {
            wx.hideLoading()
            if (res.code == 1000) {
                wx.showToast({
                    title: '提交成功',
                    icon: 'success',
                    duration: 2000
                })
                setTimeout(function(){
                    wx.navigateBack({
                        delta: 1
                    })
                },2000)
            }
        }, (err) => {
            wx.hideLoading()
            wx.showToast({
                title: err.data.message,
                icon: 'none',
                duration: 2000
            })
        })
    },
});
